package com.yegs.jltqc.controller;

import com.yegs.jltqc.TO.NamePageQuery;
import com.yegs.jltqc.VO.BasePlan;
import com.yegs.jltqc.VO.BaseQuota;
import com.yegs.jltqc.config.Msg;
import com.yegs.jltqc.service.BasePlanService;
import com.yegs.jltqc.service.BaseQuotaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/baseQuota")
public class BaseQuotaController {

    @Autowired
    private BaseQuotaService baseQuotaService;

    @PostMapping("/save")
    public Msg save(@RequestBody BaseQuota baseQuota){
        try{
            baseQuotaService.save(baseQuota);
            return Msg.success();
        }catch (Exception e){
            return Msg.error(e.getMessage());
        }
    }
    @GetMapping("/list")
    public Msg list(){
        return Msg.success("list",baseQuotaService.list());
    }

    @PostMapping("/query")
    public Msg query(@RequestBody NamePageQuery query){
        return Msg.success("page",baseQuotaService.query(query));
    }



    @GetMapping("/get")
    public Msg get(@RequestParam Long id){
        return Msg.success("data",baseQuotaService.get(id));
    }

    @GetMapping("/del")
    public Msg del(@RequestParam Long id){
        try{
            baseQuotaService.del(id);
            return Msg.success();
        }catch (Exception e){
            return Msg.error(e.getMessage());
        }
    }

}
